package com.dp;

public class Solution02 {
    public int fib(int n) {
        if (n <= 1) return n;
        int dp0 = 0;
        int dp1 = 1;
        int res = 0;
        for (int i = 2; i <= n; i++) {
            res = dp0 + dp1;
            dp0 = dp1;
            dp1 = res;
        }
        return res;
    }
}
